<template>
  <view class="container screen-width">
    <view class="top_bar">
      <view class="logo">
        <image src="../../static/tabBar/logo.png"></image>
      </view>
      <view class="search_bar">
        <view class="location" @tap="selectLocation">
          {{ city }}
          <!-- 字体图标开始 -->
          <svg
            t="1615946699743"
            class="icon"
            viewBox="0 0 1024 1024"
            version="1.1"
            xmlns="http://www.w3.org/2000/svg"
            p-id="2034"
            width="200"
            height="200"
          >
            <path
              d="M230.56060922 329.85011292c-32.74599016 0-53.69192362 43.72842908-28.60286236 68.81893873L483.84324265 680.57554913c16.17275477 16.16406441 40.21607637 16.16406441 56.38158917 0L822.12263893 398.67701781c24.45249259-24.45973456 5.38367629-68.81893873-28.19441556-68.81893873l-563.36833834-0.00796616z"
              fill="#ffffff"
              p-id="2035"
            ></path>
          </svg>
          <!-- 字体图标结束 -->
        </view>
        <view class="search_bar_top">
          <text
            :class="currentIndex == index ? 'active' : ''"
            v-for="(item, index) in titleItem"
            :key="index"
            @tap="currentItem(index, item.itemValue)"
            >{{ item.itemText }}</text
          >
        </view>
        <view class="search_barimage">
          <input
            type="text"
            @focus="getHistoryList"
            v-if="titleItem[currentIndex] && titleItem[currentIndex].itemText"
            :placeholder="`输入你要查询的` + titleItem[currentIndex].itemText.split('查')[1]"
            v-model="keyWord"/>
          <image src="../../static/tabBar/search_icon.png" @tap="handleBtn"></image>
          <!-- 查企业列表-->
          <view
            class="dataBox"
            v-if="currentIndex == 0">         
            <view class="list-content">
              <view v-show="!showHistory && companyNameItem.length>0">
                <view
                  class="policy_item"
                  hover-class="none"
                  @tap="goToCompanyList(item.companyId,item.companyName)"
                  v-for="(item, index) in companyNameItem"
                  :key="index">
                  <p v-html="item.companyName"></p>
                </view>
              </view>
              <!-- 历史记录 -->
              <view v-show="showHistory">
                <view
                  class="policy_item"
                  hover-class="none"
                  @tap="goToCompanyList(item.companyId,item.companyName)"
                  v-for="(item, index) in searchList"
                  :key="index">
                  <p v-html="item.companyName"></p>
                </view>
              </view>
              <view v-if="searchList.length > 0 && showHistory" class="flex items-middle flex-end search-history-btn">
                <view @tap="toMore">更多历史</view>
                <view @tap="toClear">清空历史</view>
              </view>
            </view>
          </view>
          <!-- 查政策列表 -->
          <view
            class="dataBox"
            v-if="policy.length > 0 && keyWord != '' && currentIndex == 1">
            <view class="list-content">
              <view
                class="policy_item"
                @tap="gotoPolicy(item.policyId, item.title)"
                v-for="(item, index) in policy"
                :key="index">
                <p v-html="item.title"></p>
              </view>
            </view>
          </view>
          <!-- 查项目列表 -->
          <view
            class="dataBox"
            v-if="projectList.length > 0 && keyWord != '' && currentIndex == 2">
            <view class="list-content">
              <view
                class="policy_item"
                @tap="gotoProject(item.projectName)"
                v-for="(item, index) in projectList"
                :key="index"
              >
                <p v-html="item.projectName"></p>
              </view>
            </view>
          </view>
        </view>
        <view class="search_bar_keyword">
          <view class="title">热门搜索:</view>
          <view class="keyWord">
            <span
              v-for="(item, index) in keyItem"
              :key="index"
              @tap="hanlderItem(item.sourceId, item.name)"
              >{{ item.name }}</span
            >
          </view>
        </view>
      </view>
    </view>
    <!-- 滚动时固定 -->
    <!-- 搜索框顶固 -->
    <div class="fixation_box screen-width" v-show="isfixed">
      <div class="fixation_search">
        <view class="search_bar">
          <input
            type="text"
            v-if="titleItem[currentIndex] && titleItem[currentIndex].itemText"
            :placeholder="
              `输入你要查询的` + titleItem[currentIndex].itemText.split('查')[1]
            "
            v-model="keyWord"
          />
          <image
            src="../../static/proty/search_icon.png"
            mode=""
            @tap="handleBtn"
          />
        </view>
      </div>
      <div class="fixation_title">
        <view
          :class="contentTitleItem == index ? 'active' : ''"
          class="title_item"
          @tap="hanlderEvent(index)"
          v-for="(item, index) in titleContent"
          :key="index"
          >{{ item }}</view
        >
      </div>
      <view class="sreach_content">
        <!-- 查企业 -->
        <ul
          v-if="
            companyNameItem.length > 0 &&
            keyWord != '' &&
            currentIndex == 0 &&
            isfixed
          "
        >
          <li
            @tap="goToCompanyList(item.companyId,item.companyName)"
            class="list"
            v-for="(item, index) in companyNameItem"
            :key="index"
          >
            <p v-html="item.companyName"></p>
          </li>
        </ul>
        <!-- 查政策 -->
        <ul
          v-if="
            policy.length > 0 && keyWord != '' && currentIndex == 1 && isfixed
          "
        >
          <navigator
            class="list"
            hover-class="none"
            @tap="gotoPolicy(item.policyId, item.title)"
            v-for="(item, index) in policy"
            :key="index"
            ><p v-html="item.title"></p
          ></navigator>
        </ul>
        <!-- 查项目 -->
        <ul
          v-if="
            projectList.length > 0 &&
            keyWord != '' &&
            currentIndex == 2 &&
            isfixed
          "
        >
          <navigator
            hover-class="none"
            @tap="gotoProject(item.projectName)"
            v-for="(item, index) in projectList"
            :key="index"
          >
            <p v-html="item.projectName"></p>
          </navigator>
        </ul>
      </view>
    </div>
    <!-- 顶部标题 -->
    <view class="tabBar">
      <navigator
        hover-class="none"
        url="/pages/policy/policySubscription"
        redirect
        class="image_content"
      >
        <image src="../../static/home/policy_icon.png" mode=""></image>
        <span>政策订阅</span>
      </navigator>
      <navigator
        hover-class="none"
        url="/pages/compare/index"
        redirect
        class="image_content"
      >
        <image src="../../static/home/enterprise_icon.png" mode=""></image>
        <span>企业对比</span>
      </navigator>
      <view @tap="isCard" class="image_content">
        <image src="../../static/home/card.png" mode=""></image
        ><span>名片</span>
      </view>
    </view>
    <view class="content">
      <view class="title_text">
        <span
          v-for="(item, index) in titleContent"
          :class="contentTitleItem === index ? 'active' : ''"
          :key="index"
          @tap="hanlderEvent(index)"
          >{{ item }}</span
        >
      </view>
      <!-- 首页内容 -->
      <navigator
        class="content_text"
        :url="`/pages/policy/policyDetails?id=${item.policyId}&inform=通知`"
        hover-class="className"
        v-show="titleContent.length > 0 && contentTitleItem == 0"
        v-for="(item, index) in getInformation"
        :key="index"
      >
        <view class="title">
          {{ item.title }}
        </view>
        <view class="name_data">
          <text class="departmentName">{{ item.label }}</text>
          <text class="endTime" v-if="item && item.date">{{
            item.date
          }}</text>
        </view>
      </navigator>

      <!-- 订阅 -->
      <view class="subscription_list" v-if="contentTitleItem == 1">
        <view
          class="subscription_item"
          v-for="(item, index) in getSubscript"
          :key="index"
          @tap="goSubscriptDelis(item.id)"
        >
          <view class="subscription_item_title">
            {{ item.title }}
          </view>
          <view class="subscription_item_ctn">
            <text class="departmentName">{{ item.departmentName }}</text>

            <text class="endTime">{{ item.createTime.split(" ")[0] }}</text>
          </view>
        </view>
        <van-divider v-if="showText">我也是有底线的</van-divider>
      </view>
      <view
        class="no_subscript"
        v-show="controlSubscript && contentTitleItem == 1"
      >
        <image :src="$imgUrl + 'static/no_subscription.png'"/>
        <p>
          你还没有订阅的部门<navigator
            url="/pages/policy/policySubscription"
            class="className"
            >点我去订阅</navigator
          >
        </p>
      </view>
      <view class="no_subscript" v-show="contentTitleItem == 1 && isLogin">
        <image :src="$imgUrl + 'static/noLogin.png'" />
        <p>
          你还没有登录，<text @tap="goToLogin" class="goLogin"
            >点我去登录</text
          >
        </p>
      </view>
      <!-- 升级会员提示(查询企业数量已满) -->
      <van-overlay
        type="primary"
        v-show="visible"
        :close-on-click-overlay="false"
      >
        <promptDialogBox
          :content="`/static/home/attention.png`"
          :msg="msg"
          :affirm="`升级会员`"
          @closeShow="handleClose"
          @controlShow="hanldClick"
        />
      </van-overlay>
    </view>
    <!-- <van-popup
      v-model="maskShow"
      closeable
      @close="onClose"
    >
      <view class="festival">
        <view class="photo">
          <img src="../../static/qiu.png">
        </view>
        <view class="see-btn" @click="toFestivalDetail">点击查看</view>
      </view>
    </van-popup> -->
  </view>
</template>

<script>

import AMap from "../../util/map/Amap.js";
var QQMapWX = require('@/static/qqmap-wx-jssdk/qqmap-wx-jssdk.js');
import { companyList,policyList,projectList } from '../../util/api/es.js'
import { debounce } from '../../util/debounce.js'
import { getCode } from '../../util/address.js'
import {deleteSearch,searchHistoryList} from '../../util/api/company.js'
export default {
  data() {
    return {
      showText: false, // 显示没有数据的文字
      visible: false, // 是否显示登陆框
      currentIndex: 0, // 查企业关键字的索引
      titleItem: [], // 查企业内容
      titleContent: ["政策资讯", "我的订阅"], // 导航栏的数据
      contentTitleItem: 0, // 切换导航栏的索引
      keyWord: "", // 输入的内容
      keyItem: [], //关键字列表
      companyNameItem: [], // 企业列表
      policy: [], // 政策列表
      projectList: [], // 查项目列表
      getInformation: [], // 获取资讯信息
      isLogin: false, // 是否有登录
      isSubsctiption: false, // 暂无没有订阅
      getSubscript: [], // 获取订阅列表
      msg: "", // 提示信息
      controlSubscript: false, // 控制是否有订阅列表
      total: 0, // 总页数
      pageNo: 0, // 政策资讯
      pageNo1: 1, // 订阅列表
      isfixed: false, // 是否固定搜索框和标题
      resAmap: "", // 地图的结果集
      map: "", // 地图实例

      timeId:'',
      qqmapsdk: '',
      province: '',
      city: "定位中...",
      area: '',
      longitude: '',
      latitude: '',
      selectCity: false, // 能不能选择城市
      pageSize: 20 ,
      query:{},
      searchList: [],
      showHistory: false //是否显示搜索历史
      // maskShow: true
    };
  },
  onShow() {
    this.getSubscript = [];
    this.getList();

    let city = uni.getStorageSync("city");
    let currentLocation = uni.getStorageSync("currentLocation");
    if (city && currentLocation) {
      this.city = city;
      this.getContentInfo(0);
    } else {
      this.getLocation()
    }

  },
  onLoad(query) {
    this.query = query
    // 获取标题
    this.getTitleItem();
    // 获取关键字
    this.getKeywrod("company");

    this.$store.dispatch("getCityNameError")

    uni.setStorageSync("province", '');
    uni.setStorageSync("city", '');
    uni.setStorageSync("currentLocation", '');
    
    this.getSearchHistory()
  },
  watch: {
    currentIndex(val) {
      if (val) {
        this.keyWord = "";
        this.policy = [];
        this.companyNameItem = [];
        this.projectList = [];
      }
    },
    keyWord: debounce(function(e){
      this.keyWord = e.trim()
      if(e.trim() !== ''){
        this.showHistory = false
        this.changeValue()
      }else{
        this.showHistory = true
        this.companyNameItem = []
      }
    },1000)
  },
  // 页面滚动的高度
  onPageScroll(e) {
    if (Math.floor(e.scrollTop) >= 340) {
      this.isfixed = true;
    } else {
      this.isfixed = false;
    }
  },
  // 上拉加载更多
  onReachBottom() {
    // debugger
    // 加载下一页
    if (this.contentTitleItem == 0) {
      this.pageNo = this.pageNo + 1;
      if (this.total > this.getInformation.length) {
        this.getContentInfo(0);
      } else {
        this.showText = true;
        uni.showToast({
          title: "没有更多内容啦",
          duration: 2000,
        });
      }
    } else if (this.contentTitleItem == 1) {
      this.pageNo1 = this.pageNo1 + 1;
      if (this.total > this.getSubscript.length) {
        this.getList();
      } else {
        this.showText = true;
      }
    }
  },

  methods: {
    // 历史搜索记录
    getSearchHistory() {
      searchHistoryList({pageNo: 1,pageSize: 10}).then(res=>{
        if(res.code === 200) {
          this.searchList = res.result.records
        }
      })
    },
    toClear() {
      let _this = this
      uni.showModal({
          title: '提示',
          content: '确定清空历史记录',
          cancelText: "考虑一下",
          success(res) {
              if (res.confirm) {
                  deleteSearch().then(res=>{
                      if(res.code === 200) {
                          uni.showToast({
                            title: "操作成功",
                            duration: 2000,
                            icon: "none",
                          })
                          this.searchList = []
                          _this.getSearchHistory()
                      }
                  })
              }
          }
      })
    },
    toMore() {
        uni.navigateTo({
          url: '/pages/mime/searchHistory'
        })
    },
    // input获取焦点时，显示企业搜索历史
    getHistoryList() {
      if (this.currentIndex == 0 && this.keyWord === "") {
        this.getSearchHistory()
        this.showHistory = true
      }else{
        this.showHistory = false
      }
    },
    getStorage(){
      //判断本地信息是否有值,如果有直接获取
        let city = uni.getStorageSync("city");
        let currentLocation = uni.getStorageSync("currentLocation"); // 当前定位

        if (city && currentLocation) {
          this.city = city;
          this.getContentInfo(0);
        } else {
          this.getLocation()
        }
    },
    // 从本地中获取定位
    getLocation() {
      this.$get("/bmj-api/api/sys/depart/getSubInfo",{}).then(res => {
        if (res.result.province !== '' && res.result.city !== '') {
        // if (res.result.province === '' && res.result.city === '') {
          // uni.setStorageSync("city", '东莞市'); // 城市名
          // uni.setStorageSync("province", '广东省'); // 省份名
          // uni.setStorageSync("currentLocation", '东莞市');
          uni.setStorageSync("province", res.result.province)
          uni.setStorageSync("city", res.result.city)
          uni.setStorageSync("currentLocation", res.result.city)
          this.selectCity = false
          this.city = uni.getStorageSync("city")
          this.getContentInfo(0)
        } else {
          this.selectCity = true;
          this.init()
        }
      })
    },
    // 获取经纬度，腾讯地图接口解析
    init() {
      uni.webView.getEnv((res)=>{
        // console.log(55555,res)
      if(res.miniprogram){
          let locationCache =  uni.getStorageSync('wx_location');
          let location = locationCache?locationCache:this.query
          if(location.longitude&&location.latitude){
              this.latitude = location.latitude;
              this.longitude = location.longitude;
              this.handleLocation()
              return
          }
      }else{
        var that = this;
        uni.getLocation({
          type: 'gcj02',
          geocode: true,
          success: (res) => {
            // console.log("获取经纬度成功",res);
            this.latitude = res.latitude;
            this.longitude = res.longitude;
            // 解析地址
            this.handleLocation()
          },
          fail: (err) => {
            this.init()
          }
        })
      }
      })
    },
    handleLocation(){
        let location = this.latitude + ',' + this.longitude
        this.$get("/bmj-api/api/tencent/getLocation",{location:location}).then(res=>{
          // console.log(666666,res)
          this.$nextTick(function() {
            this.province = res.result.ad_info.province; // 省               
            this.city = res.result.ad_info.city; // 市               
            this.area = res.result.ad_info.district; // 区
            uni.setStorageSync("province", this.province);
            uni.setStorageSync("city", this.city);
            uni.setStorageSync("currentLocation", this.city);
            this.getContentInfo(0);
          })
        })
    },

    // 选择城市
    selectLocation() {
      if(this.selectCity){
          uni.navigateTo({
          url: "/pages/index/selectLocation",
        });
        this.getInformation = []; // 赋值都将清空
      }else{}

    },

    // 点击查政策列表内容
    gotoPolicy(id, val) {
      if (this.currentIndex == 1) {
        this.keyWord = "";
        this.policy = [];
        this.$matcheHTML(val); // 去除html标签
        uni.navigateTo({
          url: "/pages/policy/policyDetails?id=" + id + "&inform=通知",
        });
      }
    },
    // 点击查项目列表内容
    gotoProject(val) {
      // console.log(val);
      val = this.$matcheHTML(val); // 去除html标签
      if (this.currentIndex == 2) {
        this.keyWord = "";
        this.projectList = [];
        uni.navigateTo({
          url: `/pages/project/index?title=${val}`,
        });
      }
    },
    // 点击查公司列表内容
    goToCompanyList(id,companyName) {
      if (this.currentIndex == 0) {
        this.keyWord = "";
        this.companyNameItem = [];
        if (companyName){
          let temp = companyName.replace(/<\/?.+?>/g, "");
          companyName = temp.replace(/ /g, "");
        }
        uni.navigateTo({
          url: `/pages/enterpriseDetails/brand_detail?id=${id}&type=1&name=${companyName}&liIndex=0&showNew=true`
        });
      }
    },
    // 点击搜索按钮
    handleBtn() {
      if (this.currentIndex == 0) {
        // 查企业
        if (this.keyWord == "") {
          // 当企业为空时,做提示
          uni.showToast({
            title: "请输入企业名称",
            duration: 2000,
            icon: "none",
          });
          return;
        }
        uni.navigateTo({
          url:
            "/pages/enterpriseDetails/findCompany?type=company&enterprise=" +
            this.keyWord,
        });
      } else if (this.currentIndex == 1) {
        // 查政策
        if (this.keyWord == "") {
          // 当企业为空时,做提示
          uni.showToast({
            title: "请输入您想要查询的政策",
            duration: 2000,
            icon: "none",
          });
          return;
        }
        uni.navigateTo({
          url: "/pages/policy-check/index?title=" + this.keyWord,
          // url: `/pages/policy/index?title=${this.keyWord}`
        });
      } else if (this.currentIndex == 2) {
        if (this.keyWord == "") {
          // 当项目搜索框为空时,做提示
          uni.showToast({
            title: "请输入您想要查询的项目",
            duration: 2000,
            icon: "none",
          });
          return;
        }
        // console.log(345);
        uni.navigateTo({
          url: "/pages/project/index?title=" + this.keyWord,
        });
      }
    },
    // 获取订阅列表
    getList() {
      // 判断是不是有token
      let token = this.$getToken();
      if (!token) {
        this.isLogin = true;
        return;
      }
      uni.showLoading({
        title: "加载中",
      });
      this.$post(
        "/bmj-api/api/pms/pmsPolicyNoticeInfo/queryMySubscribeDepartmentNotice?pageNo=" +
          this.pageNo1 + "&pageSize=" + this.pageSize
      ).then((res) => {
        if (res.code == 200 && !res.result.records.length) {
          this.controlSubscript = true;
          this.getSubscript = [];
          uni.hideLoading();
        } else if (res.code == 200 && res.result.records != null) {
          let { total, records } = res.result;
          this.total = total; // 总页数
          uni.hideLoading();
          this.getSubscript.push(...records); // 数据
        }
      });
    },

    // 点击查项目的列表项
    examProject(id, val) {
      uni.navigateTo({
        url: "/pages/project/index?title=" + val,
      });
    },
    // 获取标题(请求)
    getTitleItem() {
      this.$get("/bmj-api/api/home/getHomeDictConfigInfo").then((res) => {
        if (res.code == 200) {
          this.titleItem = res.result;
        }
      });
    },
    // 点击关键字(热门搜索)
    hanlderItem(id, val) {
      if (this.currentIndex == 0) {
        uni.navigateTo({
          url: `/pages/enterpriseDetails/brand_detail?id=${id}&type=1&liIndex=0&showNew=true`,
        });
      } else if (this.currentIndex == 1) {
        uni.navigateTo({
          url: "/pages/policy-check/index?title=" + val,
        });
      } else if (this.currentIndex == 2) {
        uni.navigateTo({
          url: "/pages/project/index?title=" + val,
        });
      }
    },
    // 获取信息(政策资讯)
    getContentInfo(index) {
      let city = uni.getStorageSync("city") || "";
      if (this.contentTitleItem == 0 && index == 0) {
        uni.showLoading({
          title: "加载中",
        });
        let city = uni.getStorageSync("city");
        let province = uni.getStorageSync("province");
				let area = ''
				// console.log('111111',this.dataItem.province,this.dataItem.city,this.dataItem.area)
				let params = {
					beginDate: "",
					dq: getCode(province,city,area),
					endDate: "",
					pageIndex: this.pageNo,
					pageSize: this.pageSize,
					policyId: "",
					source: '',
					title: '',
					userID: ""
				}
				this.$post("/bmj-api/api/es/Policy/queryPolicyList.json",params).then((res)=>{
					if (res.retCode === 0) {
            uni.hideLoading();

						if(this.pageNo === 0){
							this.getInformation = res.data.content || []
						}else{
							this.getInformation = this.getInformation.concat(res.data.content);
						}
						this.total = res.data.totalElements;
					} else if (res.retCode == 200 && !res.data.content.length) {
            uni.hideLoading();
          }
				})
      } else if (this.contentTitleItem == 1 && index == 1) {
        this.getList(); // 获取订阅列表数据
      }
    },

    currentItem(index, val) {
      this.currentIndex = index;
      this.keyWord = ''
      this.getKeywrod(val);
      this.showHistory = false
    },
    // 监听输入框的值
    changeValue() {
      this.showHistory = false
      if (this.currentIndex === 0 && this.keyWord !== "") {
        this.getCompanyList()
      } else if (this.currentIndex === 1 && this.keyWord !== "") {
        this.getPolicyList()
      } else if (this.currentIndex == 2 && this.keyWord !== "") {
        this.getProjectList()
      }
    },
    // 控制弹出层显示或隐藏
    hanldClick() {
      this.visible = false;
      // 跳转到会员页面
      uni.navigateTo({
        url: "/pages/VIP/index",
      });
    },
    handleClose() {
      this.visible = false;
    },
    // 去名片
    isCard() {
      let token = this.$getToken();
      if (!token) {
        uni.showToast({
          title: "请登录后,再操作",
          duration: 2000,
          iocn: "none",
        });
        uni.setStorageSync("pageUrl", window.location.href);
        uni.navigateTo({
          url: "/pages/login/index",
        });
      } else {
        uni.navigateTo({
          url: "/pages/person/CardList",
        });
      }
    },
    // 获取关键字
    getKeywrod(val) {
      this.$get("/bmj-api/api/home/getSearchKeywordsInfo", { type: val }).then((res) => {
          this.keyItem = res.result;
        }
      );
    },
    // 获取政策资讯和订阅的列表
    hanlderEvent(index) {
      this.contentTitleItem = index;
      this.getContentInfo(index); // 传递索引
    },
    // 点击订阅列表详情
    goSubscriptDelis(id) {
      // 跳转到政策通知
      uni.navigateTo({
        url: "/pages/policy/policyDetails?id=" + id + "&inform=通知",
      });
    },
    // 输入框企业查询
    getCompanyList(){
      let obj = {
        companyName: this.keyWord,
        pageIndex: 0,
        pageSize: 10,
        province: "",
      };
      companyList(obj).then((res) => {
        if (res.retCode == 0 && res.data.content.length) {
          let result = this.$changeText(
            res.data.content,
            "companyName",
            this.keyWord
          );
          this.companyNameItem = result;
        }
      })
    },
    // 输入框政策查询
    getPolicyList(){
      let city = uni.getStorageSync("city");
      let province = uni.getStorageSync("province");
      let area = ''
      let obj = {
        pageIndex: 0,
        pageSize: 10,
        dq: getCode(province,city,area),
        source: "",
        title: this.keyWord,
      };
      policyList(obj).then((res) => {
        if (res.retCode == 0 && res.data.content.length) {
          let result = this.$changeText(
            res.data.content,
            "title",
            this.keyWord
          );
          this.policy = result;
        }
      })
    },
    // 输入框项目查询
    getProjectList(){
      let city = uni.getStorageSync("city");
      let province = uni.getStorageSync("province");
      let area = ''
      let obj = {
        province: province,
        city: city,
        area: area,
        projectName: this.keyWord,
        pageIndex: 0,
        pageSize: 1000,
      };
      projectList(obj).then((res) => {
        if (res.retCode == 0 && res.data.content.length != 0) {
          let result = this.$changeText(
            res.data.content,
            "projectName",
            this.keyWord
          );
          this.projectList = []
          var temp = []
          for (let i = 0; i < result.length; i++) {
            if(temp.indexOf(result[i].projectName) == -1){
                temp.push(result[i].projectName);
                this.projectList.push(result[i])
            }
          }
        } else {
          uni.showToast({
            title: res.message,
            duration: 2000,
            icon: "none",
          });
          this.projectList = [];
        }
      });
    },

    // 点击登录
    goToLogin() {
      uni.setStorageSync("pageUrl", window.location.href);
      uni.navigateTo({
        url: "/pages/login/index",
      });
    },
    // onClose() {
    //   this.maskShow = false
    // },
    // 中秋活动详情
    // toFestivalDetail() {
    //   this.maskShow = false
    //   uni.navigateTo({
    //     url: '/pages/festival/Index'
    //   })
    // }
  }
};
</script>

<style lang="less" scoped>
.container {
  .top_bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    // padding-bottom: 30px;
    background-image: url(https://dm-bmj.oss-cn-guangzhou.aliyuncs.com/static/index-bg.png);
    background-size: cover;
    height: 520rpx;
    .logo {
      max-width: 320rpx;
      height: 80rpx;
      image {
        max-width: 320rpx;
        height: 80rpx;
      }
    }
    .search_bar {
      width: 100%;
      position: relative;
      padding: 0 56rpx 0;
      .location {
        display: flex;
        align-items: center;
        position: absolute;
        padding: 10rpx 30rpx;
        // border: 1rpx solid #ccc;
        font-size: 14px;
        left: 30rpx;
        top: -160rpx;
        color: #fff;
        svg {
          width: 40rpx;
          height: 30rpx;
          margin-left: 10rpx;
        }
      }
      .search_bar_top {
        text {
          padding: 10rpx 20rpx;
          font-size: 14px;
          margin-right: 25rpx;
          color: #fff;
          border-radius: 48rpx;
          &.active {
            font-weight: 700;
            background-color: #44a2ff;
          }
        }
      }
      .search_barimage {
        display: flex;
        position: relative;
        align-items: center;
        justify-content: space-around;
        background-color: #fff;
        border-radius: 6rpx;
        margin: 32rpx 0rpx;
        padding: 10rpx;
        width: 100%;
        input {
          color: #000;
          width: 500rpx;
          height: 60rpx;
          font-size: 12px;
          background-color: #fff;
          &:placeholder {
            color: #ccc;
          }
        }
        image {
          width: 35rpx;
          height: 35rpx;
        }
        .dataBox {
          z-index: 999;
          position: absolute;
          width: 620rpx;
          background-color: #fff;
          top: 80rpx;
          overflow-y: auto;
          .list-content {
            display: flex;
            // flex-wrap: wrap;
            flex-direction: column;
            overflow-y: auto;
            // padding: 0 20rpx;
            max-height: 500rpx;
            .policy_item{
              padding: 0 20upx;
              box-sizing: border-box;
            }
            .search-history{
              view{
                font-size: 12px;
                padding: 5upx 10upx;
                background: #eee;
                margin-bottom: 5px;
              }
            }
            .search-history-btn{
              background: #eee;
              padding: 20upx 10upx;
              box-sizing: border-box;
              view{
                margin-right: 20upx;
                font-size: 24upx;
                color: #999;
              }
            }
            .policy_item {
              display: flex;
              align-items: center;
              font-size: 12px;
              height: 70rpx;
              border-bottom: 1rpx solid #e4e4e4;
              overflow: hidden;
              white-space: nowrap;
              &:hover {
                color: #44a2ff;
              }
            }
          }
        }
      }
      .search_bar_keyword {
        min-height: 40px;
        display: flex;
        align-items: center;
        color: #fff;
        .title {
          width: 150rpx;
          font-size: 14px;
        }
        .keyWord {
          // display: flex;
          // flex: 1;
          // flex-wrap: wrap;

          span {
            margin: 0 10rpx;
            font-size: 14px;
            color: #9fc2f1;
          }
        }
        p {
        }
      }
    }
  }
  /* 固定样式 */
  .fixation_box {
    width: 100%;
    z-index: 100;
    // display: none;
    position: fixed;
    top: 0;
    left: 0;
    border-bottom: 1rpx solid #ccc;
    .fixation_search {
      height: 120rpx;
      background-color: #2862ad;
      padding: 20rpx 40rpx;
      .search_bar {
        display: flex;
        align-items: center;
        background-color: #fff;
        padding: 0 20rpx;
        height: 100%;
        border-radius: 10rpx;
        input {
          width: 100%;
          height: 100%;
        }
        image {
          width: 32rpx;
          height: 32rpx;
        }
      }
    }
    .fixation_title {
      height: 100rpx;
      display: flex;
      align-items: center;
      padding: 0 30px;
      background-color: #fff;
      .title_item {
        position: relative;
        width: 40%;
        font-size: 14px;
        color: #aaa;
        text-align: center;
        &.active {
          color: #333;
          font-weight: 700;
          font-size: 18px;
          &::before {
            content: "";
            position: absolute;
            left: 40%;
            bottom: -30rpx;
            width: 30rpx;
            height: 5px;
            border-radius: 4rpx;
            background-color: #1678ff;
          }
        }
      }
    }
    .sreach_content {
      min-width: 620rpx;
      position: relative;
      // margin:0 auto;
      ul {
        min-width: 660rpx;
        position: absolute;
        top: 30rpx;
        left: 50%;
        right: 50%;
        transform: translate(-50%, -50%);
        background-color: #fff;
        max-height: 300rpx;
        overflow-y: auto;
        .list {
          white-space: nowrap;
          height: 60rpx;
          line-height: 60rpx;
          padding-left: 10rpx;
          border-bottom: 1rpx solid #ccc;
          p {
          }
        }
      }
    }
  }

  .tabBar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background-color: #fff;
    margin-bottom: 12rpx;
    height: 200rpx;
    .image_content {
      display: flex;
      font-size: 14px;
      flex-direction: column;
      justify-items: center;
      align-items: center;
      image {
        width: 96rpx;
        height: 96rpx;
      }
      span {
        color: #3c4d5b;
        margin-top: 10rpx;
      }
    }
  }
  .content {
    background-color: #fff;
    padding-bottom: 100rpx;
    .title_text {
      height: 120rpx;
      display: flex;
      border-bottom: 1rpx solid #ebebeb;
      span {
        width: 40%;
        height: 100%;
        display: flex;
        font-size: 14px;
        align-items: center;
        justify-content: center;
        &.active {
          position: relative;
          font-weight: 700;
          font-size: 18px;
          &::before {
            content: "";
            position: absolute;
            left: 40%;
            bottom: 0px;
            width: 40rpx;
            height: 5px;
            border-radius: 20rpx;
            background-color: #4e98ff;
          }
        }
      }
    }
  }
  .content_text {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding: 20rpx 30rpx;
    border-bottom: 1rpx solid #ebebeb;
    .title {
      font-size: 16px;
      font-weight: 700;
      margin-bottom: 20rpx;
    }
    .name_data {
      font-size: 14px;
      color: #c7c7c7;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .departmentName {
        max-width: 50%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .endTime {
      }
      // span {
      //   margin-right: 40rpx;
      //   &:last-child {
      //     margin-left: 40rpx;
      //     margin-right: 0rpx;
      //   }
      // }
    }
  }
  .no_subscript {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    padding: 118rpx 0;
    image {
      width: 320rpx;
      height: 172rpx;
    }
    .goLogin {
      color: #1678ff;
    }
    p {
      display: flex;
      font-size: 14px;
      margin-top: 40rpx;
      color: #3c4d5b;
      .className {
        color: #44a2ff;
        // font-size: 28rpx;
      }
    }
  }
  .subscription_list {
    padding: 0 30rpx;
    padding-bottom: 55rpx;
    .subscription_item {
      display: flex;
      flex-direction: column;
      padding: 40rpx 15rpx;
      border-bottom: 1rpx solid #ccc;
      .subscription_item_title {
        font-size: 16px;
        color: #333;
        font-weight: 700;
      }
      .subscription_item_ctn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        color: #aaaaaa;
        font-size: 13px;
        margin-top: 20rpx;
        .departmentName {
          max-width: 50%;
          /* 显示省略号 */
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
        .endTime {
        }
      }
    }
  }
}
.van-popup{
  background: rgba(255,255,255,0);
}
.festival{
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        .photo{
            width: 500rpx;
            height: 300rpx;
            img{
                width: 500rpx;
                height: 300rpx;
                margin-left: 20rpx;
            }
        }
        .see-btn{
            margin-top: 20rpx;
            padding: 10rpx 50rpx;
            border-radius: 50rpx;
            color: #ffffff;
            font-size: 26rpx;
            background: linear-gradient(90deg,#1d6d40, #30855f);
        }
    }
</style>
